﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.Support.Constants;

namespace MS.InformationManagement.Presenter.SearchRadicado
{
    public class SearchRadicadoPresenter : BasePresenter<ISearchRadicadoView>
    {
        
        #region Constructors

        public SearchRadicadoPresenter(ISearchRadicadoView view) : base(view){}

        #endregion

        #region Public Methods

        public void SearchValidation()
        {
            var bllObject = new BLL.SearchRadicado.SearchRadicado();
            if (View.Source == "entrada")
                bllObject.ValidateItems(new List<string>() { GlobalConstants.CTTN_RADICADO_EMPRESA, GlobalConstants.CTTN_RADICADO_PERSONA, GlobalConstants.CTTN_RADICADO_INTERNO }, View.SelectedItems[0]);
            bllObject.TRDValidation(View.SelectedItems[0]);
        }

        public void SearchTRDValidation()
        {
            new BLL.SearchRadicado.SearchRadicado().TRDValidation(View.SelectedItems[0]);
        }

        public void SearchItems()
        {
            int totalRecords;
            if (View.Source == "entrada")
                View.FoundedItems = new BLL.SearchRadicado.SearchRadicado().SearchRadicados(View.RadicadoId, View.Nit, View.Cedula, View.Source, View.FechaInicial, View.FechaFinal, View.PageIndex, View.PageSize, out totalRecords);
            else
                View.FoundedItems = new BLL.SearchRadicado.SearchRadicado().SearchRadicados(View.RadicadoId, View.Nit, View.Cedula, View.Source, string.Empty, string.Empty, View.PageIndex, View.PageSize, out totalRecords);

            View.TotalRecords = totalRecords;
            View.LoadFoundedItems();
        }

        public void HandleLoad()
        {
            View.AllowedRibbonActions = MS.InformationManagement.BLL.AllowingAccessControl.AllowingAccessControl.GetRibbonAllowedActionsCurrentUser();
            View.Show();
        }

        #endregion

    }
}
